﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OCRTheNewHope
{   

    public class Feature
    {
        public static Random rnd = new Random();

        public double EntropyGain;

        // public static double[] ThresholdCandidates { get; set; } // thresholds for minus and plus
        public double[] ThresholdCandidates { get; set; }
        public double Threshold;

        public Rectangle Rectangle0 { get; private set; }

        public void SetThreshold(int idx1)
        {
            Threshold = this.ThresholdCandidates[idx1];
        }

        public Feature(RectangleType rectType)
        {
            this.ThresholdCandidates = new double[Parameters.NumberOfThresholds];

            for (int i = 0; i < Parameters.NumberOfThresholds; i++)
            {
                this.ThresholdCandidates[i] = rnd.NextDouble();
            }

            Rectangle0 = new Rectangle(rectType);         
        }

        public Feature(Point p1, Point p2)
        {
            this.ThresholdCandidates = new double[Parameters.NumberOfThresholds];

            for (int i = 0; i < Parameters.NumberOfThresholds; i++)
            {
                this.ThresholdCandidates[i] = rnd.NextDouble();
            }

            Rectangle0 = new Rectangle(p1,p2);
        }

        public override string ToString()
        {
            return "(" + this.Rectangle0.A.X.ToString() + ", " + this.Rectangle0.A.Y.ToString() + "), W: " + this.Rectangle0.Width.ToString() + ", H: " + this.Rectangle0.Height.ToString();                  
        }
    }
}
